<?php
namespace LinuxCheck;
class Check{
    /**
     * 检测reids服务
     */
    function checkRedis(){
        if(!$this->docheck('redis')){
            exec("/caimiao/app/redis-2.8.19/src/redis-server &", $output, $returnvar);
        }
    }

    /**
     * 检测出库单队列监听进程是否运行
     */
    function checkshipmentrequest(){
        if(!$this->docheck('api/doqueueByshipmentrequest')){
            echo 'start doqueueByshipmentrequest';
            exec("/usr/local/php/bin/php /home/user/OA/cli.php api/doqueueByshipmentrequest", $output, $returnvar);
        }else{
            echo 'doqueueByshipmentrequest is working;';
        }

    }


    function docheck($checkObj){
        $command = "ps -ef | grep '".$checkObj."' | grep -v grep | wc -l";
        exec($command, $output, $returnvar);
        $count = $output[0];
        return $count;
    }
     

}

$check = new Check();
$check->checkshipmentrequest();
